using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input.Touch;
using Rocuna.Controls;
using Rocuna.GameEngine.Extension.WP7.Input.Constants;
using Rocuna.GameEngine.Input;

namespace Rocuna.GameEngine.Extension.WP7.Controls
{
    /// <summary>
    /// Button derived class to hangel buttons for WP7.
    /// </summary>
    public class PhoneButton : Button
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Button"/> class.
        /// </summary>
        public PhoneButton(Game game)
            : base(game)
        {
            var inputManager = Game.GetService<InputManager>();
            inputManager.RegisterActionToDevice(
                PhoneDevices.PhoneGestureDevice, GestureType.Tap, o =>
                {
                    if (this.Border.Contains(((GestureSample)o).Position))
                        RaiseClickEvent();
                });
            inputManager.RegisterActionToDevice(
                PhoneDevices.PhoneGestureDevice, GestureType.DoubleTap, o =>
                {
                    if (this.Border.Contains(((GestureSample)o).Position))
                        RaiseDoubleClick();
                });
        }

        public override void Initialize()
        {
            base.Initialize();


        }
    }
}